package com.sinbader.xiaole.common.entity;


import cn.stylefeng.guns.sys.core.util.UserKit;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import com.sinbader.xiaole.common.enums.Status_;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 基础实体类 提供共有的属性
 *
 * @author sunshine
 * @version 1.0
 */
public abstract class BaseEntity implements Serializable {

    /**
     * 默认
     */
    private static final long serialVersionUID = 1L;

    /**
     * 数据状态是否删除  0 未删除
     *                          1 已删除
     */
    private Integer isDelete;

    /**
     * 创建人
     */
    private Long createUser;


    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改人
     */
    private Long updateUser;

    /**
     * 修改时间
     */
    private Date updateTime;

    /**
     * 审核人
     */
    private Long auditUser;

    /**
     * 审核时间
     */
    private Date auditTime;

    /**
     * 打印时间
     */
    private Date printTime;

    /**
     * 经手人
     */
    private Long handleUser;
    /**
     * 打印时间
     */
    private String printTimeStr;

    /**
     * 审核时间str
     */
    private String auditTimeStr;

    private static final Long SYSTEM_USER = 1L;

    public BaseEntity() {
        try {
            if (UserKit.getUser() != null) {
                User user =UserKit.getUser();
                this.createUser = user.getUserId();
                this.updateUser = user.getUserId();
            }
            else {
                this.createUser = SYSTEM_USER;
                this.updateUser = SYSTEM_USER;
            }
            this.isDelete = Status_.IsdeleteEnum.undelete.getId();
            this.createTime = new Date();
            this.updateTime = new Date();
        }
        catch (Exception e) {
            this.createUser = SYSTEM_USER;
            this.updateUser = SYSTEM_USER;
            this.isDelete = Status_.IsdeleteEnum.undelete.getId();
            this.createTime = new Date();
            this.updateTime = new Date();
        }
    }
    /**
     * 修改时间字符串
     */
    private String updateTimeStr;
    /**
     * 修改时间字符串
     */
    private String createTimeStr;

    /**
     * 获取 createUser
     *
     * @return createUser.
     */
    public Long getCreateUser() {
        return createUser;
    }

    /**
     * 设置 createUser
     *
     * @param createUser createUser
     */
    public void setCreateUser(Long createUser) {
        this.createUser = createUser;
    }

    /**
     * 获取 createTime
     *
     * @return createTime.
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * 设置 createTime
     *
     * @param createTime createTime
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * 获取 updateUser
     *
     * @return updateUser.
     */
    public Long getUpdateUser() {
        return updateUser;
    }

    /**
     * 设置 updateUser
     *
     * @param updateUser updateUser
     */
    public void setUpdateUser(Long updateUser) {
        this.updateUser = updateUser;
    }

    /**
     * 获取 updateTime
     *
     * @return updateTime.
     */
    public Date getUpdateTime() {
        return updateTime;
    }

    /**
     * 设置 updateTime
     *
     * @param updateTime updateTime
     */
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * 设置 auditUser
     *
     * @param auditUser auditUser
     */
    public void setAuditUser(Long auditUser) {
        this.auditUser = auditUser;
    }

    /**
     * 设置 handleUser
     *
     * @param handleUser handleUser
     */
    public void setHandleUser(Long handleUser) {
        this.handleUser = handleUser;
    }

    /**
     * 获取 updateTimeStr
     * @return updateTimeStr.
     */
    public String getUpdateTimeStr() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(this.getUpdateTime());
    }

    /**
     * 设置 updateTimeStr
     * @param updateTimeStr updateTimeStr
     */
    public void setUpdateTimeStr(String updateTimeStr) {
        this.updateTimeStr = updateTimeStr;
    }

    /**
     * 获取 createTimeStr
     *
     * @return createTimeStr.
     */
    public String getCreateTimeStr() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(this.getCreateTime());
    }

    /**
     * 设置 createTimeStr
     *
     * @param createTimeStr createTimeStr
     */
    public void setCreateTimeStr(String createTimeStr) {
        this.createTimeStr = createTimeStr;
    }

    /**
     * 获取 isDelete
     *
     * @return isDelete.
     */
    public Integer getIsDelete() {
        return isDelete;
    }

    /**
     * 设置 isDelete
     *
     * @param isDelete isDelete
     */
    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    /**
     * 获取 auditUser
     *
     * @return auditUser.
     */
    public Long getAuditUser() {
        return auditUser;
    }

    /**
     * 获取 handleUser
     *
     * @return handleUser.
     */
    public Long getHandleUser() {
        return handleUser;
    }

    /**
     * 获取 auditTime
     *
     * @return auditTime.
     */
    public Date getAuditTime() {
        return auditTime;
    }

    /**
     * 设置 auditTime
     *
     * @param auditTime auditTime
     */
    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }

    /**
     * 获取 printTime
     *
     * @return printTime.
     */
    public Date getPrintTime() {
        return printTime;
    }

    /**
     * 设置 printTime
     *
     * @param printTime printTime
     */
    public void setPrintTime(Date printTime) {
        this.printTime = printTime;
    }

    /**
     * 获取 printTimeStr
     *
     * @return printTimeStr.
     */
    public String getPrintTimeStr() {
        if (null != this.getPrintTime()){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return sdf.format(this.getPrintTime());
        }
        return printTimeStr;
    }

    /**
     * 设置 printTimeStr
     *
     * @param printTimeStr printTimeStr
     */
    public void setPrintTimeStr(String printTimeStr) {
        this.printTimeStr = printTimeStr;
    }

    /**
     * 获取 auditTimeStr
     *
     * @return auditTimeStr.
     */
    public String getAuditTimeStr() {
        if (null != this.getAuditTime()){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return sdf.format(this.getAuditTime());
        }
        return auditTimeStr;
    }

    /**
     * 设置 auditTimeStr
     *
     * @param auditTimeStr auditTimeStr
     */
    public void setAuditTimeStr(String auditTimeStr) {
        this.auditTimeStr = auditTimeStr;
    }
}
